Imports System.IO

Public Class Encrypt

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim di As New IO.DirectoryInfo(Application.StartupPath & "\enc\")
        Dim diar1 As IO.FileInfo() = di.GetFiles()
        Dim dra As IO.FileInfo
        'list the names of all files in the specified directory
        Dim f_mem As MemoryStream

        For Each dra In diar1
            If dra.Extension = ".bin" Then
                f_mem = New MemoryStream(arrayLoad(dra.FullName))
                arrayDump(CryptResource(f_mem, True).ToArray, ReplaceExtension(dra.FullName, "enc"))
            End If
        Next
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim di As New IO.DirectoryInfo(Application.StartupPath & "\enc\")
        Dim diar1 As IO.FileInfo() = di.GetFiles()
        Dim dra As IO.FileInfo
        'list the names of all files in the specified directory
        Dim f_mem As MemoryStream

        For Each dra In diar1
            If dra.Extension = ".enc" Then
                f_mem = New MemoryStream(arrayLoad(dra.FullName))
                arrayDump(CryptResource(f_mem, False).ToArray, ReplaceExtension(dra.FullName, "dec"))
            End If
        Next
    End Sub
End Class